package com.nf.dao;

import java.sql.Connection;
import java.sql.DriverManager;

public class HisConnectionImpl implements HisConnection {
        private static final String DRIVER_CLASS = "com.mysql.cj.jdbc.Driver";
        private static final String SERVER_IP = "127.0.0.1";// 服务器IP地址
        private static final String DATABASE_NAME = "git01";// 连接到哪一个数据库
        private static final String USER_NAME = "root";// 用户名
        private static final String PASSWORD = "654321";// 密码

        public Connection getConnection() {

            Connection conn = null;
            String jdbcUrl = "jdbc:mysql://"+SERVER_IP+":3306/"+DATABASE_NAME+"?useSSL=false&serverTimezone=UTC";
            try {
                Class.forName(DRIVER_CLASS);
                conn = DriverManager.getConnection(jdbcUrl, USER_NAME, PASSWORD);
            } catch (Exception e) {
                System.out.println("获取连接时，异常" + e.getMessage());
                conn = null;
            }
            return conn;
        }

}
